local NewGame = GV:addState('NewGame')
function NewGame:enterState()
	clearLoveCallbacks()
	print("entering new game state")

	local select_input = "name"
	local name = ""
	local gender = ""
	local thread_incomplete = false

	reset_vars()
	--spawn_meta_tiles("town", maps.town.meta_tiles)


	function love.draw()

		love.graphics.print("name : ",
			64, 96)
		love.graphics.print("gender (m or f): ",
			64, 108)
		love.graphics.print(name,
			256, 96)
		love.graphics.print(gender,
			256, 108)
		love.graphics.print("Tab to switch between entries\nReturn when done",
			64, 128)

		if thread_incomplete then

			love.graphics.print("threads not yet complete", 20, 20)

		end
	end

	function love.update(dt)

		global_updates(dt)


	end

	function love.keypressed(key, unicode)
		if select_input == "name" then
			if key == 'backspace' then
				name = string.sub(name,1,-2)
			elseif unicode > 31 and unicode < 127 then

				name = name .. string.char(unicode)
			end

		elseif select_input == "gender" then
			if key == 'backspace' then
				gender = string.sub(gender,1,-2)
			elseif unicode == 109 or unicode == 102
				or unicode == 77 or unicode == 70 then

				gender = string.char(unicode)
			end

		end

		if key == 'tab' then

			if select_input == "name" then
				select_input = "gender"
			elseif select_input == "gender" then
				select_input = "name"
			end

		end

		if key == 'return' then
			--if threads_complete >= 6 then
				if name ~= "" then
					data.player.name = name
				else
					data.player.name = "packie"
				end

				if gender ~= "" then
					data.player.gender = gender
				else
					data.player.gender = "f"
				end

				print("n : ", name, "g: ", gender)
				build_town()
				--update_meta_tiles(maps.town.meta_tiles)
				--print(table.tostring(maps.town))
				gv:gotoState('Town')
			--else
			--	thread_incomplete = true
			--end
		end


	end





end
function NewGame:exitState()
	print("exiting new game state")
end
